import 'package:wanxiang_app/generated/json/base/json_convert_content.dart';
import 'package:wanxiang_app/bean/msg_log_entity.dart';

MsgLogEntity $MsgLogEntityFromJson(Map<String, dynamic> json) {
  final MsgLogEntity msgLogEntity = MsgLogEntity();
  final int? code = jsonConvert.convert<int>(json['code']);
  if (code != null) {
    msgLogEntity.code = code;
  }
  final String? msg = jsonConvert.convert<String>(json['msg']);
  if (msg != null) {
    msgLogEntity.msg = msg;
  }
  final int? count = jsonConvert.convert<int>(json['count']);
  if (count != null) {
    msgLogEntity.count = count;
  }
  final List<MsgLogData>? data = (json['data'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<MsgLogData>(e) as MsgLogData).toList();
  if (data != null) {
    msgLogEntity.data = data;
  }
  return msgLogEntity;
}

Map<String, dynamic> $MsgLogEntityToJson(MsgLogEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['code'] = entity.code;
  data['msg'] = entity.msg;
  data['count'] = entity.count;
  data['data'] = entity.data.map((v) => v.toJson()).toList();
  return data;
}

extension MsgLogEntityExtension on MsgLogEntity {
  MsgLogEntity copyWith({
    int? code,
    String? msg,
    int? count,
    List<MsgLogData>? data,
  }) {
    return MsgLogEntity()
      ..code = code ?? this.code
      ..msg = msg ?? this.msg
      ..count = count ?? this.count
      ..data = data ?? this.data;
  }
}

MsgLogData $MsgLogDataFromJson(Map<String, dynamic> json) {
  final MsgLogData msgLogData = MsgLogData();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    msgLogData.id = id;
  }
  final int? userId = jsonConvert.convert<int>(json['user_id']);
  if (userId != null) {
    msgLogData.userId = userId;
  }
  final String? time = jsonConvert.convert<String>(json['time']);
  if (time != null) {
    msgLogData.time = time;
  }
  final int? status = jsonConvert.convert<int>(json['status']);
  if (status != null) {
    msgLogData.status = status;
  }
  final int? isRead = jsonConvert.convert<int>(json['is_read']);
  if (isRead != null) {
    msgLogData.isRead = isRead;
  }
  final String? remark = jsonConvert.convert<String>(json['remark']);
  if (remark != null) {
    msgLogData.remark = remark;
  }
  return msgLogData;
}

Map<String, dynamic> $MsgLogDataToJson(MsgLogData entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['user_id'] = entity.userId;
  data['time'] = entity.time;
  data['status'] = entity.status;
  data['is_read'] = entity.isRead;
  data['remark'] = entity.remark;
  return data;
}

extension MsgLogDataExtension on MsgLogData {
  MsgLogData copyWith({
    int? id,
    int? userId,
    String? time,
    int? status,
    int? isRead,
    String? remark,
  }) {
    return MsgLogData()
      ..id = id ?? this.id
      ..userId = userId ?? this.userId
      ..time = time ?? this.time
      ..status = status ?? this.status
      ..isRead = isRead ?? this.isRead
      ..remark = remark ?? this.remark;
  }
}